import { createSlice } from "@reduxjs/toolkit";
import { add } from "lodash";

const counterSlice = createSlice({
    name: "counter",
    initialState: { count: 0 },
    reducers: {
        increment: (state) => {
            state.count += 1;
        },
        decrement: (state) => {
            state.count -= 1;
        },
        addToNum: (state, action) => {
            console.log(action);
            state.count += action.payload;
        },
    }
});

const { increment, decrement, addToNum } = counterSlice.actions;
const counterReducer = counterSlice.reducer;
export { increment, decrement, addToNum };
export default counterReducer;